package kt.com.bilin.coin.ui.dialog

import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.ViewGroup
import android.view.WindowManager
import com.bilin.coin.R
import kotlinx.android.synthetic.main.dialog_recharge_confirm.*
import kt.com.bilin.coin.bean.RechargeInfoBean

class RechargeConfirmDialog(context: Context?, rechargeInfoBean: RechargeInfoBean, private val linsnter: (rechargeInfoBean: RechargeInfoBean) -> Unit) : Dialog(context!!, R.style.bottomDimLoadingdialog) {
    init {
        setContentView(R.layout.dialog_recharge_confirm)
        tvMoney.text = rechargeInfoBean.money
        tvPhone.text = rechargeInfoBean.phone
        tvJDC.text = "≈${rechargeInfoBean.principal}JDC"
        buttonConfirmRecharge.setOnClickListener {
            dismiss()
            linsnter(rechargeInfoBean)
        }
        ivClose.setOnClickListener { dismiss() }
        window?.let {
            val attributes = it.attributes
            attributes.width = getContext().resources.displayMetrics.widthPixels
            attributes.height = ViewGroup.LayoutParams.WRAP_CONTENT
            it.attributes = attributes
            it.setGravity(Gravity.BOTTOM)
        }
    }
}